﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;

namespace WPFLibraryReservation
{
    public sealed class WaitForInput<T> :NativeActivity<T>
    {
        public WaitForInput() : base() { }
        public string BookmarkName { get; set; }
        public OutArgument<T> Input { get; set; }

        void Continue(NativeActivityContext context, Bookmark bookmark, object obj)
        {
            Input.Set(context, (T)obj);
        }

        protected override void Execute(NativeActivityContext context)
        {
            context.CreateBookmark(BookmarkName, new BookmarkCallback(this.Continue));
        }
        protected override bool CanInduceIdle
        {
            get
            {
                return true;
            }
        }

    }
}
